@extends('layout.main')
@section('content')

<div class="col-sm-8 blog-main">
    <div class="blog-post">
        <div style="display:inline-flex">
                <h2 class="blog-post-title">{{$post->title}} {{Auth::user()->can('update', $post)}} </h2>

                @if (Auth::user()->can('update', $post))
                <a style="margin: auto"  href="/posts/{{$post->id}}/edit">
                    <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>
                </a>
                @endif
                @if (Auth::user()->can('delete', $post))
                <a style="margin: auto"  href="/posts/{{$post->id}}/delete">
                <span class="glyphicon glyphicon-remove" aria-hidden="true"></span>
                </a>
                @endif
        </div>

        <p class="blog-post-meta">{{$post->created_at->toFormattedDateString()}} by <a href="#">{{$post->user->name}}</a></p>

        <p><p>{!!$post->content!!}</p><p><br></p></p>
        <div>
        @if($post->zan(\Auth::id())->exists())
        <a href="/posts/{{$post->id}}/unzan" type="button" class="btn btn-default btn-lg">取消赞</a>
        @else
        <a href="/posts/{{$post->id}}/zan" type="button" class="btn btn-primary btn-lg">赞</a>
        @endif
        </div>
    </div>

    <div class="panel panel-default">
        <!-- Default panel contents -->
        <div class="panel-heading">评论</div>

        <!-- List group -->
        <ul class="list-group">
            @foreach($post->comments as $comment)
            <li class="list-group-item">
                <h5>{{$comment->created_at}} by {{$comment->user->name}}</h5>
                <div>
                    {{$comment->content}}
                </div>
            </li>
            @endforeach
        </ul>
    </div>

    <div class="panel panel-default">
        <!-- Default panel contents -->
        <div class="panel-heading">发表评论</div>

        <!-- List group -->
        <ul class="list-group">
            <form action="/posts/{{$post->id}}/comment" method="post">
                {{csrf_field()}}
                <input type="hidden" name="post_id" value="{{$post->id}}"/>
                <li class="list-group-item" style="padding: 0;">
                    <!-- <div id="div1" style="height:350px;max-height:500px;" >
                    </div>
                    <textarea id="content"  name="content" class="form-control" placeholder="这里是内容" style="display: none;"></textarea> -->
                    <textarea name="content" class="form-control" rows="10"></textarea>
                </li>
                @include("layout.error")
                <button class="btn btn-default" type="submit" style="margin-top: 5px;">提交</button>
            </form>

        </ul>
    </div>

</div><!-- /.blog-main -->

@endsection


        
